package com.laxcen.basiclib.ui.dialog;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.laxcen.basiclib.R;
import com.laxcen.basiclib.base.BaseDialog;


/**
 * 崩溃提示框
 */
public class CrashDialog extends BaseDialog {

    public CrashDialog(Context context) {
        super(context, R.layout.dialog_crash);
        hideCancl();
        hideSubmit();
        init();
    }


    private LinearLayout mReboot,mClose,mCancel;
    private void init(){
        mReboot = findViewById(R.id.mReboot);
        mClose = findViewById(R.id.mClose);
        mCancel = findViewById(R.id.mCancel);
        mReboot.setOnClickListener(v -> {
            if(onResult!=null){
                onResult.onReboot();
            }
        });
        mClose.setOnClickListener(v -> {
            if(onResult!=null){
                onResult.onClose();
            }
        });
        mCancel.setOnClickListener(v -> {
            if(onResult!=null){
                onResult.onCancel();
            }
        });
    }

    private OnResult onResult;
    public void setOnResult(OnResult onResult){
        this.onResult = onResult;
    }
    public interface OnResult{
        void onReboot();
        void onClose();
        void onCancel();
    }

    public void setData(String title, String content){
        setTitle(title).setContent(content);
    }

    @Override
    public void onClose() {

    }

    @Override
    public boolean onCancel() {
        return true;
    }

    @Override
    public boolean onSubmit() {
        return true;
    }

}
